package srcBayes;

import java.util.HashMap;

public class Sample 
{
    HashMap<String, String> observedVariables;
    HashMap<String, String> nonObservedVariables;
    
    public Sample(
            HashMap<String, String> observedVariables,
            HashMap<String, String> nonObservedVariables) 
    {
        this.observedVariables = observedVariables;
        this.nonObservedVariables = nonObservedVariables;
    }
    
    public String GetVariableValue(String variable)
    {
        if (this.nonObservedVariables.containsKey(variable))
        {
            return this.nonObservedVariables.get(variable);
        }
        
        if (this.observedVariables.containsKey(variable))
        {
            return this.observedVariables.get(variable);
        }
        
        throw new IllegalArgumentException(
                String.format(
                        "Variable '%s' does not belong to set of known variables!",
                        variable));
    }
    
    public void SetNonObservedVariable(String variable, String value)
    {
        if (!this.nonObservedVariables.containsKey(variable))
        {
            throw new IllegalArgumentException(
                    String.format(
                            "Variable '%s' does not belong to set of non-observed variables!",
                            variable)); 
        }
        
        this.nonObservedVariables.put(variable, value);
    }

    @Override
    public String toString() {
        return String.format(
                "Sample [observedVariables=%s, nonObservedVariables=%s]",
                observedVariables, nonObservedVariables);
    }
}
